﻿using System.IO;
using System.Text;

namespace FileTransformer
{
    public interface IDataSource
    {
        byte[] GetData();
    }

    public class FileSourceItem : IDataSource
    {
        private readonly string _fileName;

        public string FileName { get { return _fileName; } }

        public FileSourceItem(string fileName)
        {
            _fileName = fileName;
        }

        public byte[] GetData()
        {
            return File.ReadAllBytes(FileName);
        }

        public override string ToString()
        {
            return string.Format("file: [{0}]", FileName);
        }
    }

    public class TextSourceItem : IDataSource
    {
        private readonly string _text;

        public string Text { get { return _text; } }

        public TextSourceItem(string text)
        {
            _text = text;
        }

        public byte[] GetData()
        {
            return Encoding.Default.GetBytes(_text);
        }

        public override string ToString()
        {
            return string.Format("text: [{0}]", _text.Substring(0, 10) + "...");
        }
    }
}
